/*
 * @(#)MaintUserRecordForm.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.user.web;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

import com.dcivision.framework.ApplicationException;
import com.dcivision.framework.SystemParameterFactory;
import com.dcivision.framework.TextUtility;
import com.dcivision.framework.bean.AbstractBaseObject;
import com.dcivision.framework.web.AbstractActionForm;
import com.dcivision.user.bean.UserRecord;

/**
  MaintUserRecordForm.java

  This class is for web form purpose.

  @author      Rollo Chan
  @company     DCIVision Limited
  @creation date   09/07/2003
  @version     $Revision: 1.13 $
*/

public class MaintUserRecordForm extends AbstractActionForm {

  public static final String REVISION = "$Revision: 1.13 $";

  private String loginName = null;
  private String loginPwd = null;
  private String modifyLoginPwd = null;
  private String firstName = null;
  private String lastName = null;
  private String fullName = null;
  private String email = null;
  private String failedAttempt = null;
  private String maxAttempt = null;
  private String pwdExpiryDay = null;
  private String lastPwdUpdateDate = null;
  private String status = null;
  private String userType = null;
  private String userLinkID = null;
  private String preference = null;
  private String locale = null;
  private String userDef1 = null;
  private String userDef2 = null;
  private String userDef3 = null;
  private String userDef4 = null;
  private String userDef5 = null;
  
  private String deleteStaff = null;

  /** Holds value of property userGroups. */
  private String[] userGroups = null;

  /** Holds value of property userRoles. */
  private String[] userRoles = null;

  public MaintUserRecordForm() {
    super();
  }

  public String getLoginName() {
    return(this.loginName);
  }

  public void setLoginName(String loginName) {
    this.loginName = loginName;
  }

  public String getLoginPwd() {
    return(this.loginPwd);
  }

  public void setLoginPwd(String loginPwd) {
    this.loginPwd = loginPwd;
  }

  public String getFirstName() {
    return(this.firstName);
  }

  public void setFirstName(String firstName) {
    this.firstName = firstName;
  }

  public String getLastName() {
    return(this.lastName);
  }

  public void setLastName(String lastName) {
    this.lastName = lastName;
  }

  public String getFullName() {
    return(this.fullName);
  }

  public void setFullName(String fullName) {
    this.fullName = fullName;
  }

  public String getEmail() {
    return(this.email);
  }

  public void setEmail(String email) {
    this.email = email;
  }

  public String getFailedAttempt() {
    return(this.failedAttempt);
  }

  public void setFailedAttempt(String failedAttempt) {
    this.failedAttempt = failedAttempt;
  }

  public String getMaxAttempt() {
    return(this.maxAttempt);
  }

  public void setMaxAttempt(String maxAttempt) {
    this.maxAttempt = maxAttempt;
  }

  public String getPwdExpiryDay() {
    return(this.pwdExpiryDay);
  }

  public void setPwdExpiryDay(String pwdExpiryDay) {
    this.pwdExpiryDay = pwdExpiryDay;
  }

  public String getLastPwdUpdateDate() {
    return(this.lastPwdUpdateDate);
  }

  public void setLastPwdUpdateDate(String lastPwdUpdateDate) {
    this.lastPwdUpdateDate = lastPwdUpdateDate;
  }

  public String getStatus() {
    return(this.status);
  }

  public void setStatus(String status) {
    this.status = status;
  }

  public String getUserType() {
    return(this.userType);
  }

  public void setUserType(String userType) {
    this.userType = userType;
  }

  public String getUserLinkID() {
    return(this.userLinkID);
  }

  public void setUserLinkID(String userLinkID) {
    this.userLinkID = userLinkID;
  }

  public String getPreference() {
    return(this.preference);
  }

  public void setPreference(String preference) {
    this.preference = preference;
  }

  public String getLocale() {
    return(this.locale);
  }

  public void setLocale(String locale) {
    this.locale = locale;
  }

  public String getUserDef1() {
    return(this.userDef1);
  }

  public void setUserDef1(String userDef1) {
    this.userDef1 = userDef1;
  }

  public String getUserDef2() {
    return(this.userDef2);
  }

  public void setUserDef2(String userDef2) {
    this.userDef2 = userDef2;
  }

  public String getUserDef3() {
    return(this.userDef3);
  }

  public void setUserDef3(String userDef3) {
    this.userDef3 = userDef3;
  }

  public String getUserDef4() {
    return(this.userDef4);
  }

  public void setUserDef4(String userDef4) {
    this.userDef4 = userDef4;
  }

  public String getUserDef5() {
    return(this.userDef5);
  }

  public void setUserDef5(String userDef5) {
    this.userDef5 = userDef5;
  }

  public String[] getUserGroups() {
    return(this.userGroups);
  }

  public void setUserGroups(String[] userGroups) {
    this.userGroups = userGroups;
  }

  public String[] getUserRoles() {
    return(this.userRoles);
  }

  public void setUserRoles(String[] userRoles) {
    this.userRoles = userRoles;
  }

  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    return super.validate(mapping, request);
  }

  public void reset(ActionMapping mapping, HttpServletRequest request) {
    super.reset(mapping, request);
    this.setID(null);
    this.setLoginName(null);
    this.setLoginPwd(null);
    this.setFirstName(null);
    this.setLastName(null);
    this.setFullName(null);
    this.setEmail(null);
    this.setFailedAttempt(null);
    this.setMaxAttempt(SystemParameterFactory.getSystemParameter("system.default_max_attempt"));
    this.setPwdExpiryDay(SystemParameterFactory.getSystemParameter("system.default_password_expiry_day"));
    this.setLastPwdUpdateDate(null);
    this.setStatus(null);
    this.setUserType(UserRecord.USER_TYPE_STAFF);
    this.setUserLinkID(null);
    this.setPreference(null);
    this.setLocale(null);
    this.setUserDef1(null);
    this.setUserDef2(null);
    this.setUserDef3(null);
    this.setUserDef4(null);
    this.setUserDef5(null);
    this.setRecordStatus(null);
    this.setUpdateCount(null);
    this.setCreatorID(null);
    this.setCreateDate(null);
    this.setUpdaterID(null);
    this.setUpdateDate(null);
    this.setUserGroups(null);
    this.setUserRoles(null);
    this.setDeleteStaff(null);
  }

  public AbstractBaseObject getFormData() throws ApplicationException {
    UserRecord tmpUserRecord = new UserRecord();
    tmpUserRecord.setID(TextUtility.parseIntegerObj(this.getID()));
    tmpUserRecord.setLoginName(this.getLoginName());
    tmpUserRecord.setLoginPwd(this.getLoginPwd());
    tmpUserRecord.setModifyLoginPwd(this.getModifyLoginPwd());
    tmpUserRecord.setFirstName(this.getFirstName());
    tmpUserRecord.setLastName(this.getLastName());
    tmpUserRecord.setFullName(this.getFullName());
    tmpUserRecord.setEmail(this.getEmail());
    tmpUserRecord.setFailedAttempt(TextUtility.parseIntegerObj(this.getFailedAttempt()));
    tmpUserRecord.setMaxAttempt(TextUtility.parseIntegerObj(this.getMaxAttempt()));
    tmpUserRecord.setPwdExpiryDay(TextUtility.parseIntegerObj(this.getPwdExpiryDay()));
    tmpUserRecord.setLastPwdUpdateDate(parseTimestamp(this.getLastPwdUpdateDate()));
    tmpUserRecord.setStatus(this.getStatus());
    tmpUserRecord.setUserType(this.getUserType());
    tmpUserRecord.setUserLinkID(TextUtility.parseIntegerObj(this.getUserLinkID()));
    tmpUserRecord.setPreference(TextUtility.parseIntegerObj(this.getPreference()));
    tmpUserRecord.setLocale(this.getLocale());
    tmpUserRecord.setUserDef1(this.getUserDef1());
    tmpUserRecord.setUserDef2(this.getUserDef2());
    tmpUserRecord.setUserDef3(this.getUserDef3());
    tmpUserRecord.setUserDef4(this.getUserDef4());
    tmpUserRecord.setUserDef5(this.getUserDef5());
    tmpUserRecord.setRecordStatus(this.getRecordStatus());
    tmpUserRecord.setUpdateCount(TextUtility.parseIntegerObj(this.getUpdateCount()));
    tmpUserRecord.setCreatorID(TextUtility.parseIntegerObj(this.getCreatorID()));
    tmpUserRecord.setCreateDate(parseTimestamp(this.getCreateDate()));
    tmpUserRecord.setUpdaterID(TextUtility.parseIntegerObj(this.getUpdaterID()));
    tmpUserRecord.setUpdateDate(parseTimestamp(this.getUpdateDate()));
    return tmpUserRecord;
  }

  public void setFormData(AbstractBaseObject baseObj) throws ApplicationException {
    UserRecord tmpUserRecord = (UserRecord)baseObj;
    this.setID(TextUtility.formatIntegerObj(tmpUserRecord.getID()));
    this.setLoginName(tmpUserRecord.getLoginName());
    this.setLoginPwd(tmpUserRecord.getLoginPwd());
    this.setModifyLoginPwd(tmpUserRecord.getModifyLoginPwd());
    this.setFirstName(tmpUserRecord.getFirstName());
    this.setLastName(tmpUserRecord.getLastName());
    this.setFullName(tmpUserRecord.getFullName());
    this.setEmail(tmpUserRecord.getEmail());
    this.setFailedAttempt(TextUtility.formatIntegerObj(tmpUserRecord.getFailedAttempt()));
    this.setMaxAttempt(TextUtility.formatIntegerObj(tmpUserRecord.getMaxAttempt()));
    this.setPwdExpiryDay(TextUtility.formatIntegerObj(tmpUserRecord.getPwdExpiryDay()));
    this.setLastPwdUpdateDate(formatTimestamp(tmpUserRecord.getLastPwdUpdateDate()));
    this.setStatus(tmpUserRecord.getStatus());
    this.setUserType(tmpUserRecord.getUserType());
    this.setUserLinkID(TextUtility.formatIntegerObj(tmpUserRecord.getUserLinkID()));
    this.setPreference(TextUtility.formatIntegerObj(tmpUserRecord.getPreference()));
    this.setLocale(tmpUserRecord.getLocale());
    this.setUserDef1(tmpUserRecord.getUserDef1());
    this.setUserDef2(tmpUserRecord.getUserDef2());
    this.setUserDef3(tmpUserRecord.getUserDef3());
    this.setUserDef4(tmpUserRecord.getUserDef4());
    this.setUserDef5(tmpUserRecord.getUserDef5());
    this.setRecordStatus(tmpUserRecord.getRecordStatus());
    this.setUpdateCount(TextUtility.formatIntegerObj(tmpUserRecord.getUpdateCount()));
    this.setCreatorID(TextUtility.formatIntegerObj(tmpUserRecord.getCreatorID()));
    this.setCreateDate(formatTimestamp(tmpUserRecord.getCreateDate()));
    this.setUpdaterID(TextUtility.formatIntegerObj(tmpUserRecord.getUpdaterID()));
    this.setUpdateDate(formatTimestamp(tmpUserRecord.getUpdateDate()));
  }

  public String getModifyLoginPwd() {
  	return modifyLoginPwd;
  }
  
  public void setModifyLoginPwd(String modifyLoginPwd) {
  	this.modifyLoginPwd = modifyLoginPwd;
  }
  
  public String getDeleteStaff() {
    return deleteStaff;
  }
  
  public void setDeleteStaff(String deleteStaff) {
    this.deleteStaff = deleteStaff;
  }
}
